package com.myschool.dao.impl;

import com.myschool.dao.GradeDao;
import com.myschool.pojo.Grade;
import com.myschool.util.BaseDao;

import java.util.List;

public class GradeDaoImpl implements GradeDao {
    @Override
    public int add(Grade grade) {
        String sql = "INSERT INTO grade(gradeID,gradeName) values(?,?)";
        return BaseDao.executeUpdate(sql,grade.getGradeId(),grade.getGradeName());
    }

    @Override
    public int updateGrade(Grade grade) {
        String sql = "update grade set gradeName = ? where gradeID = ?;";
        return BaseDao.executeUpdate(sql,grade.getGradeName(),grade.getGradeId());
    }

    @Override
    public int deleteGrade(int gradeId) {
        String sql = "delete from grade where gradeID=?;";
        return BaseDao.executeUpdate(sql,gradeId);
    }

     public List showGrade(Class classz) {
        String sql = "select * from"+"  "+classz.getSimpleName();
        return  BaseDao.show(sql,classz);
     }

    @Override
    public List findByGradeId(int id,Class classz) {
        String sql = "select * from"+"  "+classz.getSimpleName()+"  "+"where gradeid="+id;
        return BaseDao.show(sql,classz,id);
    }
}
